/**
 * $Revision: 1.0 $
 * $Author: Eric Yang $
 * $Date: Mar 25, 2010 12:07:57 AM $
 *
 * Author: Eric Yang
 * Date  : Mar 25, 2010 12:07:57 AM
 *
 */
package com.gooex.web.action.gbuy.common;

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.c4j.string.StringTools;

import com.gooex.web.action.BaseManageableAction;

/**
 * @author Eric Yang
 * @version 1.0
 */
public class CheckEnvAction extends BaseManageableAction {
	private static final Log logger = LogFactory.getLog(CheckEnvAction.class);

	private String key;

	private String value;

	public String execute() throws Exception {
		if (StringTools.isNotBlankOrNull(key))
			System.setProperty(key, value);

		logger.debug("Properties:" + "==================================");
		Properties properties = System.getProperties();
		Iterator<Object> iterator = properties.keySet().iterator();
		while (iterator.hasNext()) {
			String type = (String) iterator.next();
			logger.debug(type + " --> " + properties.getProperty(type));
		}
		logger.debug("");
		logger.debug("env:" + "==================================");
		logger.debug(System.getenv());
		logger.debug("");

		// System.setProperty("file.encoding", "UTF-8");

		return SUCCESS;
	}

	public Properties getProperties() {
		return System.getProperties();
	}

	public Map<String, String> getEnv() {
		return System.getenv();
	}

	public String getKey() {
		return key;
	}

	public void setKey(String key) {
		this.key = key;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
}
